﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Web.Configuration;

public partial class admin_DoiMatKhau : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnOK_OnClick(object sender, EventArgs e)
    {
        string pwd = "";
        //Kiểm tra file count_visit.txt nếu không tồn  tại thì
        if (System.IO.File.Exists(Server.MapPath("pwd.txt")) == false)
        {
            ClientScript.RegisterStartupScript(typeof(Page), "testScript", "thatbai()", true);
            return;
        }
        // Ngược lại thì
        else
        {
            // Đọc dử liều từ file count_visit.txt
            System.IO.StreamReader read = new System.IO.StreamReader(Server.MapPath("pwd.txt"));
            pwd = read.ReadLine();
            read.Close();
            // Tăng biến count_visit thêm 1
        }
        if (pwd != txtPassword1.Text)
        {
            ClientScript.RegisterStartupScript(typeof(Page), "testScript", "thatbai()", true);
            return;
        }
        pwd = txtPassword2.Text; //you can grab it from a textbox......

        System.IO.StreamWriter writer = new System.IO.StreamWriter(Server.MapPath("pwd.txt"));
        writer.WriteLine(pwd);
        writer.Close();
        ClientScript.RegisterStartupScript(typeof(Page), "testScript", "thanhcong()", true);
    }
}